package com.adee.nowcoder.huawei;

import java.util.Scanner;


public class T023_HJ24_1{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] arr = new int[n];
            for(int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }

            int[] dp = new int[n];
            for(int i = 0; i < n; i++) {
                dp[i] = 1;
            }
            int max = 1;
            int maxIdx = 0;
            for(int i = 1; i < n; i++) {
                for(int j = 0; j < i; j++) {
                    if(arr[j] < arr[i]) {
                        int len = dp[i];
                        int len1 = dp[j]+1;
                        if(len1 > len){
                            dp[i] = len1;
                        }
                    }
                }
                if(dp[i] >= max) {
                    max = dp[i];
                    maxIdx = i;
                }
            }
            System.out.println("最大递增子序列长度：" + max);
            // 根据最长递增子序列长度恢复最长递增子序列
            int[] ret = recover(dp,max,maxIdx);
        }
    }

    private static int[] recover(int[] dp, int max, int maxIdx) {

        return new int[0];
    }


    // 按字典顺序比较
    private static int[] dicPrimary(int[] a, int[] b) {
        for (int i = 0; i < a.length; i++) {
            if (a[i] < b[i]) {
                return a;
            }else if (a[i] > b[i]) {
                return b;
            }
        }
        return a;
    }

    static int[] copy(int[] arr, int inc) {
        int[] tmp = new int[arr.length + inc];
        for(int i = 0; i< arr.length; i++) {
            tmp[i] = arr[i];
        }
        return tmp;
    }

    static void print(int[] arr) {
        if (arr == null || arr.length == 0) return;
        for (int i : arr) {
            System.out.print(i + " ");
        }
        System.out.println();
    }
    }
